package com.liu.model;

import java.util.Date;

import org.json.JSONException;
import org.json.JSONObject;

public class Pwd {
	private String pUUID, UUID, pwd, ecmy;

	public String getEcmy() {
		if (ecmy == null)
			return "";
		return ecmy;
	}

	public void setEcmy(String ecmy) {
		this.ecmy = ecmy;
	}

	private int Xh;
	private Date createTime;

	public String getpUUID() {
		return pUUID;
	}

	public void setpUUID(String pUUID) {
		this.pUUID = pUUID;
	}

	public String getUUID() {
		return UUID;
	}

	public void setUUID(String uUID) {
		UUID = uUID;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public int getXh() {
		return Xh;
	}

	public void setXh(int xh) {
		Xh = xh;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public JSONObject toJsonObj() throws JSONException {
		JSONObject obj = new JSONObject();
		obj.put("pUUID", getpUUID());
		obj.put("UUID", getUUID());
		obj.put("pwd", getPwd());
		obj.put("xh", getXh());
		obj.put("createTime", createTime.getTime());
		return obj;
	}

	public static Pwd JsonToGroup(JSONObject obj) throws JSONException {
		Pwd ac = new Pwd();
		ac.setUUID(obj.getString("UUID"));
		ac.setPwd(obj.getString("pwd"));
		ac.setpUUID(obj.getString("pUUID"));
		ac.setXh(obj.getInt("xh"));
		ac.setCreateTime(new Date(obj.getLong("createTime")));
		return ac;
	}
}
